
package io.lckgroup.modules.lck.config;

import io.lckgroup.modules.lck.interceptor.WeixinAuthorizationInterceptor;
import io.lckgroup.modules.lck.resolver.WeixinLoginUserHandlerMethodArgumentResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * MVC配置
 */
@Configuration
public class WeixinMvcConfig implements WebMvcConfigurer {
    @Autowired
    private WeixinAuthorizationInterceptor weixinAuthorizationInterceptor;
    @Autowired
    private WeixinLoginUserHandlerMethodArgumentResolver weixinLoginUserHandlerMethodArgumentResolver;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(weixinAuthorizationInterceptor).addPathPatterns("/mp/**");
    }

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
        argumentResolvers.add(weixinLoginUserHandlerMethodArgumentResolver);
    }
}